package org.yn.base.util;

import org.yn.emp.domain.Employee;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

public class LoginContext {
    public static Map<String,Object> loginMap = new HashMap<>();

    public static List<String> userAuth=new LinkedList<>();

    public static Employee getLoginUser(HttpServletRequest request){
        String token = request.getHeader("token");
//        if (StringUtils.isEmpty(token)){
//            throw new RuntimeException("未登录请重新登录");
//        }
        Object user = loginMap.get(token);
        if (Objects.nonNull(user)){
            return (Employee)user;
        }else{
            Employee employee = new Employee();
            employee.setId(1L);
            employee.setUsername("默认管理员");
            return employee;
        }
    }

}
